<template>
  <div class="article-item scale-1px-hairline--hot">
    <div class="content"  @click="goInfo(item)">
      <div class="left-cnt">
        <h3 class="title">{{item.articleTitle}}</h3>
        <div class="attr">
          <p class="source">
            <span class="name">{{item.publisher}}</span>
            <span class="time">{{item.createTime | formatData}}</span>
          </p>
          <span class="read">{{item.scanNum}}次阅读</span>
        </div>
      </div>
      <div class="img">
        <img :src="item.articleImg" alt="">
      </div>
    </div>
  </div>
</template>
<script>
import { formatTimeByArticle } from '@/utils/tool'
import { mapGetters } from 'vuex'
export default {
  props:{
    item:Object
  },
  data() {
    return {
      // item:{
      //   articleId: 42598,
      //   articleImg: "http://i2.chinanews.com/simg/2019/190616/sl_100996470.jpg",
      //   articleTitle: "滕华涛携手鹿晗打造《上海堡垒》：中国科幻需要更多信心信心信心",
      //   createTime: "1569806252000",
      //   discussVOS: [],
      //   likeCount: 15,
      //   praiseAndShareUserVOS: [],
      //   praiseStatus: 0,
      //   publisher: "中国新闻网",
      //   replayCount: 5,
      //   scanNum: 4690
      // }
    }
  },
  filters: {
    formatData(time) {
      return time ? formatTimeByArticle(time) : '-'
    }
  },
  computed: {
    ...mapGetters(['userInfo']),
  },
  methods: {
    // 跳转文章详情
    goInfo(item) {
      item.scanNum += 1
      let articleId = item.articleId
      let area = this.classifyName === this.userInfo.majorCity ? this.userInfo.majorCity : '全国'
      let agentId = this.userInfo.agentId
      let enterpriseId = this.userInfo.enterpriseId
      let classify = this.classify
      this.$router.push(`/discover/${articleId}/${area}?agentId=${agentId}&enterpriseId=${enterpriseId}`)
    },
  },
}
</script>
<style lang="less" scoped>
.scale-1px-hairline--hot::after{
  background: #E4E6F0;
}
.article-item {
  overflow: hidden;
  &.noborder {
    border: none;
  }
  .content {
    display: flex;
    padding: 14px 0;
    align-items: center;
    overflow: hidden;
    .left-cnt {
      flex: 1;
      height: 83px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-right: 14px;
      .title {
        font-size: 16px;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2; //（行数）
        -webkit-box-orient: vertical;
        word-break: break-all;
        color: #13284D;
      }
      .attr {
        color: #9CA5B5;
        font-size: 12px;
        line-height: 16px;
        display: flex;
        align-items: center;
        .source {
          flex: 1;
          .name {
            display: inline-block;
            margin-right: 8px;
            max-width: 60px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: middle;
          }
          .time {
            display: inline-block;
            vertical-align: middle;
          }
        }
        .read {
          line-height: 16px;
          min-width: 60px;
          text-align: right;
          display: inline-block;
          vertical-align: middle;
        }
      }
    }
    .img {
      width: 114px;
      height: 78px;
      border-radius: 6px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 6px;
        object-fit: cover;
      }
    }
  }
}
</style>
